<template>
	<view class="bubble" :style="{width,textAlign: align,...customStyle}" :class="`${direction} ${type}`">
		<slot></slot>
		<view class="stop" v-if="showStop && stopFlag" @click="stop">停止</view>
	</view>
</template>

<script>
	export default {
		name:"bubble",
		props: {
			showStop: {
				type: Boolean,
				default: false
			},
			customStyle: {
				type: Object,
				default: () => ({})
			},
			align: {
				type: String,
				default: 'left'
			},
			width: {
				type: String,
				default: 'auto'
			},
			// 气泡的方向
			direction: {
				type: String,
				default: 'right'
			},
			type: {
				type: String,
				default: 'color',//color black
			}
		},
		data() {
			return {
				stopFlag: true
			};
		},
		methods: {
			stop() {
				this.stopFlag = false;
				this.$emit('stop')
			}
		}
	}
</script>

<style lang="scss">

.bubble {
	word-break: break-all;
	vertical-align: middle;
	box-sizing: border-box;
	white-space: pre-line;
	// padding: 30rpx;
	display: inline-block;
	// flex: 1;
	// $h:92rpx;
	// line-height: $h;
	// min-height: $h;
	border-radius: 46rpx;
	position: relative;
	.stop {
		position: absolute;
		width: 80rpx;
		right: -85rpx;
		$h: 40rpx;
		line-height: $h;
		height: $h;
		font-size: 24rpx;
		top: 20rpx;
		border-radius: math.div($h,2);
		background-color: $uni-bg-color-grey;
		color: #333;
		text-align: center;
	}
	&.color {
		background: linear-gradient(0deg, #59E785 0%, #4AEBE9 100%);
		box-shadow: 0px 6px 13px 0px rgba(0,0,0,0.41);
		color: #171717;
	}
	&.black {
		background: #2C2A3D;
		box-shadow: 0px 12px 21px 0px rgba(0,0,0,0.18);
		color: #fff;
	}
	
	&.right {
		border-bottom-right-radius: 0;
	}
	&.left {
		border-bottom-left-radius: 0;
	}
}
</style>